package com.project.config;

import com.project.util.Interceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    /**拦截*/
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new Interceptor()).addPathPatterns("/shoppingCart/buy");
    }
    /**上传图片 */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //客户端以/img/目录开始的请求，定位到服务器指定文件中访问该资源
        registry.addResourceHandler("/img/**")
                .addResourceLocations("file:E:/mavenstudy/WebInvoicingSystem/src/img/");
    }

}
